package com.test.list.simple;

/** Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

public class Controller
{
	private static Controller mInstance;
	private static Context mContext;
	private EditText mFilterText;

	public static Controller getInstance()
	{
		if (mInstance == null)
		{
			synchronized (Controller.class)
			{
				if (mInstance == null)
				{
					mInstance = new Controller();
				}
			}
		}

		return mInstance;
	}

	public void hideKeyboard()
	{
		InputMethodManager imm = (InputMethodManager) getContext()
				.getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.hideSoftInputFromWindow(mFilterText.getApplicationWindowToken(), 0);
	}

	private Controller()
	{
		super();
	}

//	/**
//	 * 
//	 * @param isPhoneNeeded
//	 * @param isEmailNeeded
//	 * @param isDisplayNameNeeded
//	 * @param isIDNeeded
//	 * @param isLookUpKeyNeeded
//	 * @return
//	 */

//	public ArrayList<String> createUserDetailsArray(boolean isPhoneNeeded,
//			boolean isEmailNeeded, boolean isDisplayNameNeeded,
//			boolean isIDNeeded, boolean isLookUpKeyNeeded)
//	{
//		ArrayList<String> retVal = new ArrayList<String>();
//		if (isPhoneNeeded)
//		{
//			retVal.add(ContactsContract.CommonDataKinds.Phone.NUMBER);
//		}
//		if (isEmailNeeded)
//		{
//			retVal.add(ContactsContract.CommonDataKinds.Email.DATA1);
//		}
//		if (isDisplayNameNeeded)
//		{
//			retVal.add(ContactsContract.Contacts.DISPLAY_NAME);
//		}
//		if (isIDNeeded)
//		{
//			retVal.add(ContactsContract.CommonDataKinds.Photo.CONTACT_ID);
//		}
//		if (isLookUpKeyNeeded)
//		{
//			retVal.add(ContactsContract.CommonDataKinds.Photo.LOOKUP_KEY);
//		}
//
//		return retVal;
//	}

//	/**
//	 * 
//	 * @param contactId
//	 * @return
//	 */
//	public Uri getContactPhotoUri(long contactId)
//	{
//		Uri photoUri = ContentUris.withAppendedId(
//				ContactsContract.Contacts.CONTENT_URI, contactId);
//		photoUri = Uri.withAppendedPath(photoUri,
//				ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
//
//		return photoUri;
//	}

	
	public static Context getContext()
	{
		return mContext;
	}

	public void setContext(Context context)
	{
		mContext = context;
	}

	public void setFilterText(EditText filterText)
	{
		mFilterText = filterText;
	}
}